/**
 * 规则相关
 * njg 2012-5-15
 */
package com.axt.dbaudit.bean.cfg;

import java.util.List;

import com.axt.dbaudit.base.MsgFuncExt;
import com.axt.dbaudit.model.cfg.AlarmPolicy;
import com.axt.dbaudit.model.cfg.AlarmRule;
import com.axt.dbaudit.model.cfg.ObjectType;
import com.axt.dbaudit.model.cfg.OperType;
import com.axt.soa.bean.BaseFuncBean;
import com.axt.soa.msg.types.MsgErrorCode;
import com.axt.soa.msg.types.MsgParam;

public class PolicyRuleBean extends BaseFuncBean {
	/**
	 * 查询所有策略
	 * 
	 * @return List<AlarmPolicy>
	 */
	public List<AlarmPolicy> queryPolicies(String serverPath) {
		prepare(serverPath);

		return fetch(MsgFuncExt.FUNC_QUERY_POLICY,
				"com.axt.dbaudit.model.AlarmPolicy", "AlarmPolicy", CONN_T_TCP);
	}

	/**
	 * 新建默认策略组
	 * 
	 * @param aServerID
	 *            审计数据库ID
	 * @param aUserId
	 *            用户ID
	 * @param aIsAuto
	 *            传入String类型,"true"\"false"
	 * @return
	 */
	public int NewDefaultGroup(String serverPath, int serverID, int userId,
			String isAuto) {
		prepare(serverPath);

		// TODO 后台 没有MSG_PARA_USER_ID_MODIFY，用的是MSG_PARA_USER_ID
		request.addParam(MsgParam.MSG_PARA_USER_ID_MODIFY, userId);
		request.addParam(MsgParam.MSG_COL_AU_SERVER_ID, serverID);
		request.addParam(MsgParam.MSG_COL_AU_ISAUTO, isAuto);
		return execute(MsgFuncExt.FUNC_INSERT_DEFAULT_GROUP, CONN_T_TCP);
	}

	/**
	 * 获得某一GroupId下的规则
	 * 
	 * @param aGroupId
	 * @return List<AlarmRule>
	 */
	public List<AlarmRule> queryRules(String serverPath, int groupId) {
		prepare(serverPath);
		
		return fetch(MsgFuncExt.FUNC_QUERY_RULE,
				"com.axt.dbaudit.model.AlarmRule", "AlarmRule", CONN_T_TCP);
	}

	/**
	 * 获得操作类型
	 * 
	 * @return
	 */
	public List<OperType> queryOperTpeys(String serverPath) {
		prepare(serverPath);
		
		return fetch(MsgFuncExt.FUNC_QUERY_OPERTYPE,
				"com.axt.dbaudit.model.OperType", "OperType", CONN_T_TCP);
	}

	/**
	 * 获得对象类型
	 * 
	 * @return
	 */
	public List<ObjectType> queryObjType(String serverPath) {
		prepare(serverPath);
		
		return fetch(
				MsgFuncExt.FUNC_QUERY_OBJTYPE,
				"com.axt.dbaudit.model.ObjectType", "ObjectType", CONN_T_TCP);
	}

}
